#include "Screen.h"
#include "Game_Manager.h"
#include "YamlParser.h"

#define SCREEN_WIDTH  640
#define SCREEN_HEIGHT 480
#define SPRITE_SIZE    32

int main( int argc, char *argv[] ){

	char pathCompleto[256];
	memset(pathCompleto, 0, sizeof(pathCompleto));

	snprintf(pathCompleto, sizeof(pathCompleto), "%s/%s", getenv("CONF_DIR"), "x.yaml");
	YamlParser parseador(string(pathCompleto));

	SDL_Event event;
	Uint8 *keystate;
	int colorkey, gameover;

	snprintf(pathCompleto, sizeof(pathCompleto), "%s/%s", getenv("CONF_DIR"), "grass.bmp");
	Screen* s = new Screen(SCREEN_WIDTH,SCREEN_HEIGHT, pathCompleto,"SDL");
	s->startSdl();
	s->load_background();
	s->load_sprite();

	//Setup sprite colorkey and turn on RLE
	colorkey = SDL_MapRGB(s->getScreen()->format, 255, 0, 255);
	SDL_SetColorKey(s->getMainSprite(), SDL_SRCCOLORKEY | SDL_RLEACCEL, colorkey);

	Game_Manager* gm = new Game_Manager(s);
	gm->gameControler();

	//Cleanup
	SDL_FreeSurface(s->getMainSprite());
	SDL_FreeSurface(s->getBackGround());
	SDL_Quit();

	return 0;

}
